package com.huawei.classroom.student.h06;

public class NonBuilding extends Role{
	public void move(int dx,int dy) {
		x+=dx;
		y+=dy;
	}
	public void attack(Role object) {
		if(object.health<=0) {
			System.out.println("Object had died, attacking failed");
			return;
		}
		if(getDistance(object)<=range) {
			object.health-=force;
			System.out.println("Attack successful");
			//判断死亡的是不是士兵，因为要统计人数
			if(object.health<=0 && (object instanceof Soldier)) {
				Soldier.LivingSoldierCount--;
				Soldier.DeadedSoldierCount++;
			}
		}
	}
}
